import 'package:fish_redux/fish_redux.dart';
import 'package:flutter/material.dart' hide Action;
import 'package:flutter/scheduler.dart';
import 'package:hayll_app_village_master/hayll/village_manager/home/village_access_robbit_component/action.dart';
import '../main_page/action.dart';
import 'action.dart';
import 'state.dart';

Effect<CompanyState> buildEffect() {
  return combineEffects(<Object, Effect<CompanyState>>{
    Lifecycle.initState: _initState,
    CompanyAction.action: _onAction,
    CompanyAction.initUI: _initUI,
  });
}

void _onAction(Action action, Context<CompanyState> ctx) {}

void _initUI(Action action, Context<CompanyState> ctx) {
  ctx.dispatch(CompanyActionCreator.refreshUI());
  ctx.dispatch(VillageAccessRobbitActionCreator.updateAccessRobbit());
}

void _initState(Action action, Context<CompanyState> ctx) {
  var controller = ctx.stfState as TickerProvider;
  ctx.state.mController = TabController(
      initialIndex: 0, length: ctx.state.tabNames.length, vsync: controller);
  ctx.dispatch(CompanyActionCreator.refreshUI());
}
